#include "file.h"

namespace asce
{
	File::File()
	{
		file_ = NULL;
		length_ = 0;
	}

	File::~File()
	{
		Close();
	}

	bool File::Open(const std::string& path)
	{
		if (valid())
		{
			return false;
		}

		file_ = fopen(path.c_str(), "w");

		return valid();
	}

	void File::Close()
	{
		if (valid())
		{
			fclose(file_);
			file_ = NULL;
			length_ = 0;
		}
	}

	int File::Write(const char* buffer, int length)
	{
		if (!valid())
		{
			return -1;
		}

		return fwrite(buffer, sizeof(char), length, file_);
	}

	int File::Read(char* buffer, int length)
	{
		return -1;
	}
}